package cn.hchaojie.javase.day03;

import org.junit.Test;

// 砖
public class DemoBrick {
	@Test
	public void test1() {
		int[][] brick = {
				{0, 0, 1},
				{1, 1, 1},
				{0, 0, 0},
		};

		int[][] brick2 = {
				{0, 1, 0},
				{0, 1, 0},
				{0, 1, 1},
		};
		
		for (int i = 0; i < brick.length; i++) {
			for (int j = 0; j < brick[i].length; j++) {
				System.out.print(brick[i][j] + " ");
			}
			
			System.out.println();
		}
	}
	
	@Test
	public void test2() {
		// 0,0 		-> 			2,0
		// 0,1		->			1,0
		// 0,2		->			0,0
		
		// 1,0		->			2,1
		// 1,1		->			1,1
		// 1,2		->			0,1
		
//		int[][] brick = {
//				{0, 0, 1},
//				{1, 1, 1},
//				{0, 0, 0},
//		};
		
		int[][] brick = {
				{0, 1, 0},
				{0, 1, 0},
				{0, 1, 1},
		};
		
		// row, col是现在的行数和列数
		int row = brick[0].length;
		int col = brick.length;
		
		int[][] brick2 = new int[row][col];
		for (int i = 0; i < row; i++) {
			for (int j = 0; j < col; j++) {
				brick2[i][j] = brick[col - j - 1][i];
			}
		}
		
		for (int i = 0; i < row; i++) {
			for (int j = 0; j < col; j++) {
				System.out.print(brick2[i][j] + " ");
			}
			
			System.out.println();
		}
	}
	
	@Test
	public void test3() {
		int[][] brick = {
				{0, 1, 0, 0},
				{0, 1, 0, 0},
				{0, 1, 0, 0},
				{0, 1, 0, 0},
		};
		
		// row, col是现在的行数和列数
		int row = brick[0].length;
		int col = brick.length;
		
		int[][] brick2 = new int[row][col];
		for (int i = 0; i < row; i++) {
			for (int j = 0; j < col; j++) {
				brick2[i][j] = brick[col - j - 1][i];
			}
		}
		
		for (int i = 0; i < row; i++) {
			for (int j = 0; j < col; j++) {
				System.out.print(brick2[i][j] + " ");
			}
			
			System.out.println();
		}
	}
}
